package cn.zwx.member.svc.domain.convert.address;

import cn.zwx.member.svc.domain.entity.MemberAddressEntity;
import cn.zwx.member.svc.dto.AddressCreateReqDTO;
import cn.zwx.member.svc.vo.AddressRespVO;
import org.springframework.beans.BeanUtils;

import java.util.Date;


/**
 * 用户收件地址 Convert
 *
 * @author zhangwenxue
 */
public class AddressConvert {


   public static MemberAddressEntity convert(AddressCreateReqDTO bean){
       MemberAddressEntity entity = new MemberAddressEntity();
       entity.setUpdateTime(new Date());
       entity.setCreateTime(new Date());
       entity.setContact(bean.getName());
       entity.setAddress(bean.getDetailAddress());
       entity.setIsDefault(bean.getDefaultStatus());
       entity.setCityId(bean.getCityId().toString());
       entity.setProvinceId(bean.getProvinceId().toString());
       entity.setDistrictId(bean.getDistrictId().toString());
       entity.setPhone(bean.getMobile());
       entity.setUserId(bean.getUserId().toString());
       return entity;
   }

    public static AddressRespVO convert(MemberAddressEntity bean){
        AddressRespVO addressRespVO = new AddressRespVO();
        BeanUtils.copyProperties(bean,addressRespVO);
        return addressRespVO;
    }

}
